#include <stdio.h>
#include "lib_fixed.h"

int main(int argc, char **argv)
{
    int i;

    printf("sizeof fixed_t = %ld..%ld bytes\n", sizeof(fixed),sizeof(fixed_t) );

    if (argc != 3)
    {
        printf("argv[]= is empty\n");
        return 1;
    }

    fixed_t a(argv[1]);
    fixed_t b(argv[2]);

    printf("a    = %s\n", a.show());
    printf("b    = %s\n", b.show());
    printf("a+b  = %s\n", (a + b).show());
    printf("a-b  = %s\n", (a - b).show());
    printf("a*b  = %s\n", (a * b).show());
    printf("-a   = %s\n", (-a).show());
    printf("b++  = %s\n", (++b).show());
    printf("a[4] = %s ... operator precision\n", a[4].show());


    if (b != 0)
       {
       printf("a/b = %s\n", (a / b).show());
       }
    printf("a.whole() = %d\n", a.whole());
    printf("is a == b? %s\n", a == b ? "yes" : "no");
    printf("is a != b? %s\n", a != b ? "yes" : "no");
    printf("is a <  b? %s\n", a <  b ? "yes" : "no");
    printf("is a <= b? %s\n", a <= b ? "yes" : "no");
    printf("is a >  b? %s\n", a >  b ? "yes" : "no");
    printf("is a >= b? %s\n", a >= b ? "yes" : "no");

    return 0;
}

